package com.example.class_code.controller;

import com.example.class_code.common.base.BaseController;
import com.example.class_code.common.result.RestResult;
import com.example.class_code.common.result.TableDataInfo;
import com.example.class_code.model.SysUserEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/demo")
public class DemoController extends BaseController {


    @PostMapping
    public RestResult add(){
        return toAjax(1);
    }

    @PutMapping
    public RestResult edit(){
        return toAjax(1);
    }

    @DeleteMapping
    public RestResult remove(){
        return toAjax(1);
    }

    @GetMapping(value = {"/","/{userId}"})
    public RestResult getInfo(@PathVariable(value = "userId",required = false) Long userId){
        RestResult ajax = RestResult.success();
        SysUserEntity user = new SysUserEntity();
        user.setUserId(userId);
        ajax.put("user",user);
        return ajax;
    }

    @GetMapping("/list")
    public TableDataInfo list(){
        return TableDataInfo.success(new ArrayList<>(),100);
    }

}
